using System;
using System.Collections.Generic;

namespace IBNet
{
   /// <summary>
   /// Scanner Subscription details to pass to Interactive Brokers
   /// </summary>
   public class ScannerSubscription
   {
      private decimal abovePrice;
      private decimal belowPrice = decimal.MaxValue;
      private int aboveVolume;
      private int averageOptionVolumeAbove;
      private decimal couponRateAbove;
      private decimal couponRateBelow = decimal.MaxValue;
      private string excludeConvertible;
      private string instrument;
      private string locationCode;
      private decimal marketCapAbove;
      private decimal marketCapBelow = decimal.MaxValue;
      private string maturityDateAbove;
      private string maturityDateBelow;
      private string moodyRatingAbove;
      private string moodyRatingBelow;
      private int numberOfRows;// = -1; // No row number specified. 49 = max numberOfRows
      private string scanCode;
      private string scannerSettingPairs;
      private string spRatingAbove;
      private string spRatingBelow;
      private string stockTypeFilter;
      private readonly List<string> scannerResults = new List<string>(50);

      #region Properties

      public List<string> ScannerResults
      {
         get { return scannerResults; }         
      }

      /// <summary>
      /// Defines the number of rows of data to return for a query.
      /// </summary>
      public int NumberOfRows
      {
         get { return numberOfRows; }
         set { numberOfRows = value; }
      }

      /// <summary>
      /// Defines the instrument type for the scan.
      /// </summary>
      public string Instrument
      {
         get { return instrument; }
         set { instrument = value; }
      }

      /// <summary>
      /// The location, currently the only valid location is US stocks.
      /// </summary>
      public string LocationCode
      {
         get { return locationCode; }
         set { locationCode = value; }
      }

      /// <summary>
      /// Can be left blank. 
      /// </summary>
      public string ScanCode
      {
         get { return scanCode; }
         set { scanCode = value; }
      }

      /// <summary>
      /// Filter out contracts with a price lower than this value.
      /// Can be left blank.
      /// </summary>
      public decimal AbovePrice
      {
         get { return abovePrice; }
         set { abovePrice = value; }
      }

      /// <summary>
      /// Filter out contracts with a price higher than this value.
      /// Can be left blank. 
      /// </summary>
      public decimal BelowPrice
      {
         get { return belowPrice; }
         set { belowPrice = value; }
      }

      /// <summary>
      /// Filter out contracts with a volume lower than this value.
      /// Can be left blank.
      /// </summary>
      public int AboveVolume
      {
         get { return aboveVolume; }
         set { aboveVolume = value; }
      }

      /// <summary>
      /// Can leave empty. 
      /// </summary>
      public int AverageOptionVolumeAbove
      {
         get { return averageOptionVolumeAbove; }
         set { averageOptionVolumeAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with a market cap lower than this value.
      /// Can be left blank.
      /// </summary>
      public decimal MarketCapAbove
      {
         get { return marketCapAbove; }
         set { marketCapAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with a market cap above this value.
      /// Can be left blank.
      /// </summary>
      public decimal MarketCapBelow
      {
         get { return marketCapBelow; }
         set { marketCapBelow = value; }
      }

      /// <summary>
      /// Filter out contracts with a Moody rating below this value.
      /// Can be left blank.
      /// </summary>
      public string MoodyRatingAbove
      {
         get { return moodyRatingAbove; }
         set { moodyRatingAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with a Moody rating above this value.
      /// Can be left blank.
      /// </summary>
      public string MoodyRatingBelow
      {
         get { return moodyRatingBelow; }
         set { moodyRatingBelow = value; }
      }

      /// <summary>
      /// Filter out contracts with an SP rating below this value.
      /// Can be left blank.
      /// </summary>
      public string SPRatingAbove
      {
         get { return spRatingAbove; }
         set { spRatingAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with an SP rating above this value.
      /// Can be left blank.
      /// </summary>
      public string SPRatingBelow
      {
         get { return spRatingBelow; }
         set { spRatingBelow = value; }
      }

      /// <summary>
      /// Filter out contracts with a maturity date earlier than this value.
      /// Can be left blank.
      /// </summary>
      public string MaturityDateAbove
      {
         get { return maturityDateAbove; }
         set { maturityDateAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with a maturity date later than this value.
      /// Can be left blank.
      /// </summary>
      public string MaturityDateBelow
      {
         get { return maturityDateBelow; }
         set { maturityDateBelow = value; }
      }

      /// <summary>
      /// Filter out contracts with a coupon rate lower than this value.
      /// Can be left blank.
      /// </summary>
      public decimal CouponRateAbove
      {
         get { return couponRateAbove; }
         set { couponRateAbove = value; }
      }

      /// <summary>
      /// Filter out contracts with a coupon rate higher than this value.
      /// Can be left blank.
      /// </summary>
      public decimal CouponRateBelow
      {
         get { return couponRateBelow; }
         set { couponRateBelow = value; }
      }

      /// <summary>
      /// Filter out convertible bonds.
      /// Can be left blank.
      /// </summary>
      public string ExcludeConvertible
      {
         get { return excludeConvertible; }
         set { excludeConvertible = value; }
      }

      /// <summary>
      /// Can leave empty. For example, a pairing "Annual, true" used on the
      /// "top Option Implied Vol % Gainers" scan would return annualized volatilities.
      /// </summary>
      public string ScannerSettingPairs
      {
         get { return scannerSettingPairs; }
         set { scannerSettingPairs = value; }
      }

      /// <summary>
      /// ALL (excludes nothing)
      /// STOCK (excludes ETFs)
      /// ETF (includes ETFs)
      /// </summary>
      public string StockTypeFilter
      {
         get { return stockTypeFilter; }
         set { stockTypeFilter = value; }
      }

      #endregion
   }
}